<%-- 
    Document   : gest_utenti
    Created on : 10-apr-2014, 15.10.20
    Author     : micheleprola
--%>

<%@page import="entity.Utente"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <title>SportingEventClub - Gestione Utenti</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" type="text/css" href="CSS/BaseSite.css" />
        <link rel="stylesheet" type="text/css" href="CSS/vertical-ticker.css"/>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <script type="text/javascript" src="JQuery/jquery.totemticker.js"></script>
        <link rel="shortcut icon" href= "Images/stadion-icon.png"/>
    </head>
    <body>
        <div class="main">
            <div class="page">
                <div class="header">       
                    <div class="login">
                        <%@include file="login.jsp"%>
                    </div>
                    <div class="banner">
                    </div>
                    <div class="topmenu">
                        <%@include file="topmenu.jsp" %>
                    </div>
                </div>
                <div class="content">
                    <div class="content-in">
                        <div class="left-panel">
                            <div class="left-panel-in">
                               <%if(user == null || flag != 1){ %>
                                    <%@include file="erroresession.jsp"%>
                               <%}else{%>
                               <div align='center'><h2>Elenco utenti</h2><br/>
                                    <% String mode = (String) request.getAttribute("mode");
                                        if(mode==null){}
                                        else if(mode.equals("permessoUtente")){
                                    %>
                                            <br/><h4 style='color:red;'>Modificati i permessi dell'utente selezionato: reso Amministratore</h4>
                                        <%}else if(mode.equals("permessoAmministratore")){%>
                                            <br/><h4 style='color:red;'>Modificati i permessi dell'utente selezionato: reso Utente</h4>
                                        <%}else if(mode.equals("eliminato")){%>
                                            <br/><h4 style='color:red;'>L'utente selezionato è stato rimosso dal portale</h4>
                                        <%}%>
                                </div>
                                        <%
                                            List<Utente>utenti =(List<Utente>)request.getAttribute("utenti");
                                            if(utenti.isEmpty()){
                                        %>
                                                <div align='center'><h3>Non sono presenti utenti oppure sei l'unico utente del portale</h3></div>
                                            <%}else{%>
                                                <table border = "1" cellspacing="0" class="tablevisualizzaUtente">
                                                    <thead><tr class="riga_dispari"><th>Utente</th><th>Permesso</th><th>Operazione</th></tr></thead>
                                                    <tbody>
                                                    <%
                                                        for(int i=0; i<utenti.size();i++){
                                                        if(!utenti.get(i).getNomeUtente().equals(user)){
                                                    %>
                                                            <form  action="GeneralController" method="post">
                                                                <input type="hidden" id="idutente" name="idutente" value="<%=utenti.get(i).getId()%>">
                                                                <%if(i%2==0){%>
                                                                    <tr class="riga_pari">
                                                                <%}else{%>
                                                                    <tr class="riga_dispari">
                                                                <%}%>
                                                                        <td><%=utenti.get(i).getNomeUtente()%></td>
                                                                        <%if(utenti.get(i).getFlag() == -1){%>
                                                                            <td>utente non verificato</td>
                                                                            <td>
                                                                                <button type="submit" class="btnut" name="submit" value="permessiUtVerifica">Verifica</button>
                                                                        <%}else if(utenti.get(i).getFlag() == 0){%>
                                                                            <td>utente</td>
                                                                            <td>
                                                                                <button type="submit" class="btnut" name="submit" value="permessiUtAdmin">Rendi Admin</button>
                                                                        <%}else{%>
                                                                            <td>amministratore</td>
                                                                            <td>
                                                                                <button type="submit" class="btnut" name="submit" value="permessiUtUtente">Rendi Utente</button>
                                                                        <%}%>
                                                                                &nbsp;&nbsp;&nbsp;&nbsp;
                                                                                <button type="submit" class="btnut" name="submit" value="eliminaUt">Elimina</button> 
                                                                            </td>
                                                                    </tr>
                                                            </form>
                                                            <%}%>
                                                    <%  }%>
                                                </table>
                                            <%}%>
                                    <%}%>
                            </div>
                        </div>
                        <div class="right-panel">
                            <div class="right-panel-in">
                                <jsp:include page="/GeneralController">
                                    <jsp:param name="submit" value="right-content"/>
                                    <jsp:param name="op" value="newsbox"/>
                                </jsp:include>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="footer">
                    <%@include file="footer.jsp" %> 
                </div>
            </div>
        </div> 
    </body>
</html>


